lr16 2.2.0
Loading...
Searching...
No Matches
lr16


LR 16 Click

LR 16 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Feb 2025.
  • Type : UART type

Software Support

Example Description

This example demonstrates the use of LR 16 Click board by showing the communication between two Click boards configured in P2P network mode.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.LR16

Example Key Functions

  • lr16_cfg_setup This function initializes Click configuration structure to initial values.
    void lr16_cfg_setup ( lr16_cfg_t *cfg );
    void lr16_cfg_setup(lr16_cfg_t *cfg)
    LR 16 configuration object setup function.
    LR 16 Click configuration object.
    Definition lr16.h:263
  • lr16_init This function initializes all necessary pins and peripherals used for this Click board.
    err_t lr16_init ( lr16_t *ctx, lr16_cfg_t *cfg );
    err_t lr16_init(lr16_t *ctx, lr16_cfg_t *cfg)
    LR 16 initialization function.
    LR 16 Click context object.
    Definition lr16.h:243
  • lr16_reset_device This function resets the device by toggling the reset pin logic state.
    void lr16_reset_device ( lr16_t *ctx );
    void lr16_reset_device(lr16_t *ctx)
    LR 16 reset device function.
  • lr16_cmd_run This function sends a specified command to the Click module.
    void lr16_cmd_run ( lr16_t *ctx, uint8_t *cmd );
    void lr16_cmd_run(lr16_t *ctx, uint8_t *cmd)
    LR 16 cmd run function.
  • lr16_cmd_set This function sets a value to a specified command of the Click module.
    void lr16_cmd_set ( lr16_t *ctx, uint8_t *cmd, uint8_t *value );
    void lr16_cmd_set(lr16_t *ctx, uint8_t *cmd, uint8_t *value)
    LR 16 cmd set function.

Application Init

Initializes the driver and logger.

void application_init ( void )
{
log_cfg_t log_cfg;
lr16_cfg_t lr16_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
lr16_cfg_setup( &lr16_cfg );
LR16_MAP_MIKROBUS( lr16_cfg, MIKROBUS_1 );
if ( UART_ERROR == lr16_init( &lr16, &lr16_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
app_state = LR16_POWER_UP;
log_printf( &logger, ">>> APP STATE - POWER UP <<<\r\n\n" );
}
#define LR16_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition lr16.h:229
void application_init(void)
Definition main.c:143
@ LR16_POWER_UP
Definition main.c:54

Application Task

Application task is split in few stages:

  • LR16_POWER_UP:

    Powers up the device, performs a device factory reset and reads system information.

  • LR16_CONFIG_EXAMPLE:

    Configures device for the LoRa P2P network mode.

  • LR16_EXAMPLE:

    Performs a LoRa P2P test example by exchanging messages with another LR 16 Click board.

void application_task ( void )
{
switch ( app_state )
{
{
if ( LR16_OK == lr16_power_up( &lr16 ) )
{
app_state = LR16_CONFIG_EXAMPLE;
log_printf( &logger, ">>> APP STATE - CONFIG EXAMPLE <<<\r\n\n" );
}
break;
}
{
if ( LR16_OK == lr16_config_example( &lr16 ) )
{
app_state = LR16_EXAMPLE;
log_printf( &logger, ">>> APP STATE - EXAMPLE <<<\r\n\n" );
}
break;
}
{
lr16_example( &lr16 );
break;
}
default:
{
log_error( &logger, " APP STATE." );
break;
}
}
}
@ LR16_OK
Definition lr16.h:287
void application_task(void)
Definition main.c:176
@ LR16_CONFIG_EXAMPLE
Definition main.c:55
@ LR16_EXAMPLE
Definition main.c:56

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.